<%-- 
    Document   : newjsp
    Created on : Jun 18, 2011, 11:32:10 PM
    Author     : Hany
--%>
<%@page import="java.util.Hashtable"%>
<%@page import="pucit.rentacarDAO"%>
<%! boolean ready = true; %>
<%
            if(session.getAttribute("username") == null){
                session.setAttribute("msg", "Only registered users can update their profile!");
                response.sendRedirect("signin.jsp");
                ready = false;
            }
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Diminishing   by Free CSS Templates</title>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />

<script type="text/JavaScript" language="JavaScript">
function validate()
{	
        var fname = document.lab7.fname.value;
	if(fname=="")
	{
		alert("Your first name is empty");
		document.lab7.fname.focus();
		return false;
	}
        
        var lname = document.lab7.lname.value;
	if(lname=="")
	{
		alert("Your last name is empty");
		document.lab7.lname.focus();
		return false;
	}
        var address=document.lab7.address.value;
	
	if(address=="")
	{
		alert("Your address is empty");
		document.lab7.address.focus();
		return false;
	}
        
        var city=document.lab7.city.value;

	if(city=="")
	{
		alert("Your city is empty");
		document.lab7.city.focus();
		return false;
	}
        
        var country=document.lab7.country.value;
        
	if(country=="")
	{
		alert("Your country is empty");
		document.lab7.country.focus();
		return false;
	}
        
        var email=document.lab7.email.value;
        
	if(email=="")
	{
		alert("Your email is empty");
		document.lab7.email.focus();
		return false;
	}

        var phone=document.lab7.phone.value;

	if(phone=="")
	{
		alert("Your phone is empty");
		document.lab7.phone.focus();
		return false;
	}
        
        var spec=document.lab7.spec.value;
        
	if(spec=="")
	{
		alert("Your spec is empty");
		document.lab7.spec.focus();
		return false;
	}
	
	var url = "controller?action=update&fname="+fname+"&lname="+lname+"&spec="+spec+"&address="+address+"&city="+city+"&email="+email+"&phone="+phone+"&country="+country;
        var check = new XMLHttpRequest();
        check.open("GET", url, false);
        check.send(null);
        var res = check.responseText;
        //document.getElementById("Ustatus").innerHTML = res;
        //return false;
        if(res.search("true") >= 0){
            document.getElementById("UstatusTrue").innerHTML = "Profile Updated Successfully!";
            return false;
        }
        else{
            document.getElementById("Ustatus").innerHTML = "Updation failed!";
            return false;
        }
	
		

}

function letternumber(event)
	{
		var key;
		var keychar;
		
		if (window.event)
		   key = window.event.keyCode;
			
		   keychar = String.fromCharCode(key);
			
		
		// alphas and numbers
		if ((("0123456789").indexOf(keychar) > -1))
		   return true;
		else
		   return false;
	}




</script>

</head>
<body>

    <p>kamran</p>
    <%! Hashtable<String,String> values; %>

    <% if(ready){ %>
    <%
    
            
                       
                                String username=session.getAttribute("username").toString();
                                rentacarDAO dao=new rentacarDAO();
                                values=dao.getDetails(username);
                
                       
           
               
        %>
    
<div id="wrapper">
	<div id="menu">
		<ul>
			<li><span><a href="index.jsp">Home</a></span></li>
			
                         <%
                            if(session.getAttribute("username") == null){
%>
			<li><a href="signin.jsp">Sign in</a></li>
                        <% } else {%>
                        <li><a href="signout.jsp">Sign out</a></li>
                        <%
                            }
    %>
    
			<li class="current_page_item"><a href="update.jsp">Update Profile</a></li>
			<li><a href="intro.jsp">About</a></li>
			<li><a href="reserve.jsp">Reserve Car</a></li>
			<li><a href="contact.jsp">Contact</a></li>
		</ul>
	</div>
	<!-- end #menu -->
	<div id="header">
		<div id="logo">
			<h1><a href="#">Rent A Car</a></h1>
		</div>
		<div id="search">
			<form method="get" action="">
				<fieldset>
					<input type="text" name="s" id="search-text" size="15" value="enter keywords here..." />
					<input type="submit" id="search-submit" value="GO" />
				</fieldset>
			</form>
		</div>
	</div>
	<div id="splash">&nbsp;</div>
	<!-- end #header -->
	<div id="page">
		<div id="page-bgtop">
			<div id="page-bgbtm">
				<div id="content">
                                    
                                    <h2 color: #2C2723;>Update Your Profile</h2>
					<form name=lab7 action="controller"  method=post onSubmit="return validate()">
<input type="hidden" name="action" value="update">
<input type="hidden" name="hide" value="">
    
<table>
    <tr>
	<td><hr/></td>
	
    </tr>
    <tr><td><font face="verdana,arial" size=-1>First Name:</td><td><input value="<%= values.get("name")%>" type="text" name="fname"></td></tr>
<tr><td><font face="verdana,arial" size=-1>Last Name:</td><td><input value="<%= values.get("lastname")%>" type="text" name="lname"></td></tr>


<tr>
	<td align="right"><font face="verdana,arial" size=-1>Address:</td>
	<td><textarea rows="2" columns="20" name="address"><%= values.get("address")%></textarea></td>
</tr>

<tr>
	<td align="right"><font face="verdana,arial" size=-1>City:</td>
	<td><input value="<%= values.get("city")%>" type="text" size="15"name="city"></td>
</tr>

<tr>
	<td align="right"><font face="verdana,arial" size=-1>Country:</td>
	<td><input value="<%= values.get("country")%>" type="text"  name="country"></td>
</tr>

<tr>
	<td align="right"><font face="verdana,arial" size=-1>Email:</td>
	<td><input value="<%= values.get("email")%>" type="text" name="email"></td>
</tr>


<tr>
	<td align="right"><font face="verdana,arial" size=-1>Phone:</td>
	<td><input value="<%= values.get("phone")%>" type="text" name="phone" onkeypress="return letternumber(event)"></td>
</tr>

<tr>
	<td align="right"><font face="verdana,arial" size=-1>profession:</td>
	<td><input value="<%= values.get("profession")%>" type="text" name="spec"></td>
</tr>

<tr>
		<td align="right"></td>
		<td><input type="submit" name="submit" value="save"></td>
	</tr>
<tr>
	<td align="right"></td>
        <td><div name="Ustatus" id="Ustatus" style="color:red"></div>
            <div name="UstatusTrue" id="UstatusTrue" style="color:green"></div></td>
</tr>





</table>
</form>
                            <h3><a href="index.jsp">Back to Home</a></h3>
                            <p>if you want to change password <a href="changepwd.jsp">click here</a></p>
				</div>
				<!-- end #content -->
				<div id="sidebar">
					<ul>
						<li>
							<h2>Solution of pollution</h2>
							<p>Pollution is a big problem of today whether it is air or noise. Environmentalists embrace hybrid cars as a solution to today's pollution problems.</p>
						</li>
						<li>
							<h2>Branches</h2>
							<ul>
								<li><a href="contact.jsp">Lahore Branch</a></li>
								<li><a href="karachi.jsp">Karachi Branch</a></li>
								<li><a href="isl.jsp">Islamabad Branch</a></li>
								<li><a href="faisal.jsp">Faisalabad Branch</a></li>
								<li><a href="rawal.jsp">Rawalpindi Branch</a></li>
								
							</ul>
						</li>
						<li>
							<h2>Menu</h2>
							<ul>
								<li><a href="hybrid.jsp">Hybrid Cars</a></li>
								<li><a href="addcar.jsp">Add Cars</a></li>
								<li><a href="delCars.jsp">Delete Cars</a></li>
								<li><a href="freeCars.jsp">Make Car Reserved free</a></li>
								<li><a href="#">Beautiful Photos</a></li>
							</ul>
						</li>
						
					</ul>
				</div>
				<!-- end #sidebar -->
				<div style="clear: both;">&nbsp;</div>
			</div>
		</div>
	</div>
	<!-- end #page -->
</div>
<div id="footer-wrapper">
	<div id="three-columns">
		<div id="column1">
			<h2>Branches</h2>
			<ul>
				<li><a href="contact.jsp">Lahore Branch</a></li>
				<li><a href="karachi.jsp">Karachi Branch</a></li>
				<li><a href="isl.jsp">Islamabad Branch</a></li>
				<li><a href="faisal.jsp">Faisalabad Branch</a></li>
				<li><a href="rawal.jsp">Rawalpindi Branch</a></li>
				
			</ul>
		</div>
		<div id="column2">
			<h2>Menu</h2>
			<ul>
				<li><a href="hybrid.jsp">Hybrid Cars</a></li>
				<li><a href="addcar.jsp">Add Cars</a></li>
				<li><a href="delCars.jsp">Delete Cars</a></li>
				<li><a href="freeCars.jsp">Make Car Reserved free</a></li>
				<li><a href="#">Beautiful Photos</a></li>
		</div>
		
	</div>
	<div id="footer">
		<p>Copyright (c) 2011 Sitename.com. All rights reserved. Design by <a href="http://www.freecsstemplates.org/"> CSS Templates</a>.</p>
	</div>
	<!-- end #footer -->
</div>

<% } %>
</body>
</html>
